<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>ZDH 人群文件首页</title>
    <meta name="keywords" content="ZDH 人群文件首页">
    <meta name="description" content="ZDH 人群文件首页">

    <link rel="shortcut icon" href="img/favicon.ico">

    <link href="css/plugins/chosen/chosen.css" rel="stylesheet">
<!--    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">-->
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="css/plugins/datetimepicker/datetimepicker.css" rel="stylesheet">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link rel="stylesheet" data-name="vs/editor/editor.main" href="js/plugins/vs/editor/editor.main.css">
    <link rel="stylesheet" href="js/plugins/vs/editor/zdh.css">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>人群文件配置</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="buttons.html#">
                            <i class="fa fa-eye"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="javascript:void(0);" onclick="getResourceDesc()">功能说明</a>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="ibox-content">

                    <form id="dispatch_task_add_form" name="dispatch_task_add_form" method="post" class="form-horizontal"
                          action="">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">运算符</label>
                            <div class="col-sm-10">
                                <select id="operate" name="operate" data-placeholder=""
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="and" mytype="">AND(当前节点和上游节点取交集)</option>
                                    <option value="or" mytype="">OR(上游节点取并集后结果和当前节点取交集)</option>
                                    <option value="not" mytype="">NOT(上游节点取交集结果排除当前节点集)</option>
                                    <option value="not_use" mytype="">NOT_USE(截断所有上游仅取当前节点结果)</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否BASE数据</label>
                            <div class="col-sm-10">
                                <select id="is_base" name="is_base" data-placeholder=""
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="true" mytype="">是</option>
                                    <option value="false" mytype="" selected>否</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">人群文件</label>
                            <div class="col-sm-10">
                                <select id="rule_id" name="rule_id" data-placeholder="选择人群文件..."
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="" mytype="">人群文件...</option>
                                </select>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否禁用</label>
                            <div class="col-sm-10">
                                <div class="checkbox i-checks">
                                    <label class="no-padding">
                                        <input id="is_disenable" name='is_disenable'  type="checkbox"><i></i> 禁用</label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">推送类型</label>
                            <div class="col-sm-10">
                                <select id="touch_type" name="touch_type" data-placeholder=""
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="database" mytype="" selected>数据库</option>
                                    <option value="queue" mytype="">消息队列</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">依赖级别</label>
                            <div class="col-sm-10">
                                <select id="depend_level" name="depend_level" data-placeholder="依赖级别"
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="0" mytype="">成功触发</option>
                                    <option value="1" mytype="">杀死触发</option>
                                    <option value="2" mytype="">失败触发</option>
                                    <option value="3" mytype="">上游完成触发</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">数据流转状态</label>
                            <div class="col-sm-10">
                                <select id="data_status" name="data_status" data-placeholder=""
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="1" mytype="">成功数据</option>
                                    <option value="2" mytype="">失败数据</option>
                                    <option value="3" mytype="">所有数据</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">超时时间</label>
                            <div class="col-sm-10">
                                <input id="time_out" name="time_out" type="text" value="86400"
                                       placeholder="任务超时时间,以秒为单位,example: 100" class="form-control" aria-required="true"> </span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">关联项目</label>
                            <div class="col-sm-10">
                                <select id="project_code" name="project_code" data-placeholder=""
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="" mytype="">空</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">关联场景</label>
                            <div class="col-sm-10">
                                <select id="project_scene" name="project_scene" data-placeholder=""
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="" mytype="">空</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">版本标识</label>
                            <div class="col-sm-10">
                                <input id="version_tag" name="version_tag" type="text" value=""
                                       placeholder="版本标识,默认为空,在多版本上线期间验证使用" class="form-control" aria-required="true"> </span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">异步执行</label>
                            <div class="col-sm-10">
                                <select id="is_async" name="is_async" data-placeholder=""
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="true" mytype="">是</option>
                                    <option value="false" mytype="" selected>否</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">重试次数</label>
                            <div class="col-sm-10">
                                <input id="plan_retry_count" name="plan_retry_count" type="text" value="0"
                                       placeholder="重试次数,example: 100" class="form-control" aria-required="true"> </span>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="text-center">
                                <button id="save_etl_info" name="save_etl_info" class="btn btn-primary" οnsubmit='return false'
                                        type="button">保存
                                </button>
                            </div>
                        </div>

                    </form>


                </div>
            </div>



        </div>
    </div>
</div>


<script src="js/zdh_common.js"></script>

<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>

<!-- Bootstrap table -->
<script src="js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

<!-- 自定义js -->
<script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="js/hplus.js?v=4.1.0"></script>
<script src="js/content.js?v=1.0.0"></script>

<!-- Chosen -->
<script src="js/plugins/chosen/chosen.jquery.js"></script>

<!-- layer javascript -->
<script src="js/plugins/layer/layer.min.js"></script>

<!-- Toastr script -->
<script src="js/plugins/toastr/toastr.min.js"></script>

<!-- iCheck -->
<script src="js/plugins/iCheck/icheck.min.js"></script>

<script src="js/plugins/layer/laydate/laydate.js"></script>

<script src="js/project_common.js"></script>
<script src="js/digitalmarket/strategy_common.js"></script>

<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });

    });

    (function(document, window, $) {


        (function () {


            var url = decodeURI(location.search); //这一条语句获取了包括问号开始到参数的最后，不包括前面的路径
            var params = url.substr(1);//去掉问号
            var pa = params.split("&");
            var s = new Object();
            for(var i = 0; i < pa.length; i ++){
                s[pa[i].split("=")[0]] = unescape(pa[i].split("=")[1]);
            }


            function init_crowd_file() {
                $.ajax({
                    type: 'POST',
                    url: server_context+"/crowd_file_list_by_owner",
                    dataType: 'json',
                    async: false,
                    data: {},
                    //成功返回
                    success: function (data) {
                        if(data.code != "200"){
                            layer.msg(data.msg);
                            return ;
                        }
                        let str = '<option value=\"\" mytype=\"\" hassubinfo=\"true\">空</option>';
                        for (let i = 0; i < data.result.length; i++) {
                            str += '<option value=\"' + data.result[i].id + "\" mytype=\""  + "\" hassubinfo=\"true\">" + data.result[i].file_name + "</option>"
                        }
                        //输入数据源类型下拉框
                        $('#rule_id').html(str);
                        $('#rule_id').chosen()
                    },
                    //处理完成
                    complete: function () {
                        console.info("complete")
                    },
                    //报错
                    error: function (data) {
                        console.info("error: " + data.responseText);
                    }
                });
            }
            init_crowd_file();
            $('#depend_level').chosen();
            $('#operate').chosen();
            $('#data_status').chosen();
            if(s["rule_id"] != '-1'){
                console.info("更新触发");
                strategy_base_param(s);
                // $("#depend_level").val(s["depend_level"]);
                // $("#depend_level").trigger("chosen:updated");
                // if (!s["time_out"] && typeof(s["time_out"])!="undefined"){
                //     $("#time_out").val(s["time_out"]);
                // }

                // $("#operate").val(s["operate"]);
                // $("#operate").trigger("chosen:updated");
                //
                // $("#data_status").val(s["data_status"]);
                // $("#data_status").trigger("chosen:updated");
                //
                // $("#touch_type").val(s.touch_type);
                // $("#touch_type").trigger("chosen:updated");
                //
                // $("#is_base").val(s.is_base);
                // $("#is_base").trigger("chosen:updated");
                //
                // $("#rule_id").val(s["rule_id"]);
                // $("#rule_id").trigger("chosen:updated");

                // var is_disenable=s['is_disenable'];
                // if(is_disenable=="true"){
                //     $('#is_disenable').iCheck('check');
                // }
                //
                // $("#project_code").val(s["project_code"]);
                // $("#project_code").trigger("chosen:updated");
                // var project_id = $('#project_code').find("option:selected").attr("mytype");
                // project_scene(project_id);
                //
                // $("#project_scene").val(s["project_scene"]);
                // $("#project_scene").trigger("chosen:updated");
                //
                // $('#version_tag').val(s.version_tag);
                //
                // $("#is_async").val(s.is_async);
                // $("#is_async").trigger("chosen:updated");
            }
        })();



    })(document, window, jQuery);

    $('#save_etl_info').click(function () {

        //自定义实现

        var rule_context= $('#rule_id').find("option:selected").text();
        var operate=$('#operate').find("option:selected").val();
        var depend_level=$('#depend_level').find("option:selected").val();
        var touch_type=$('#touch_type').find("option:selected").val();
        var is_base=$('#is_base').find("option:selected").val();
        var data_status=$('#data_status').find("option:selected").val();
        var time_out=$('#time_out').val();
        var project_code=$('#project_code').find("option:selected").val();
        var project_scene=$('#project_scene').find("option:selected").val();
        var version_tag=$('#version_tag').val();

        var rule_id = $('#rule_id').find("option:selected").val();
        var is_disenable = "false";
        if($('#is_disenable').is(':checked')){
            is_disenable="true"
        }
        var more_task  = "crowd_file";

        const data = get_strategy_base_param(more_task, rule_id, rule_context);
        data.rule_expression_cn = rule_context;
        // data={
        //     "more_task": more_task,
        //     "operate": operate,
        //     "touch_type": touch_type,
        //     "is_disenable":is_disenable,
        //     "depend_level":depend_level,
        //     "time_out": time_out,
        //     "is_base": is_base,
        //     "data_status": data_status,
        //     "project_code": project_code,
        //     "project_scene": project_scene,
        //     "version_tag": version_tag,
        //
        //     "rule_context":rule_context,
        //     "rule_id": rule_id,
        //     "rule_expression_cn": rule_context,
        // };
        console.info("job_detail:"+JSON.stringify(data));
        $("#etl_task_text",window.parent.document).val(JSON.stringify(data));
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    })
</script>


</body>

</html>
